package offer.roratearray;

public class FirstMissingPositive {
    public int firstMissingPositive(int[] nums) {
        int len = nums.length;
        boolean[] map = new boolean[len + 1];
        for (int i = 0; i <= len; i++) {
            map[i] = false;
        }
        for (int i = 0; i < len; i++) {
            if(nums[i] <= len && nums[i] >= 0){
                map[nums[i]] = true;
            }
        }
        int ans = len + 1;
        for (int i = 1; i <= len; i++) {
            if(!map[i]){
                ans = i;
                break;
            }
        }
        return ans;
    }
}
